import java.util.Stack;

class StockSpanner {
    // 定义一个栈，用来存储
    public Stack<Integer> s;
    
    StockSpanner() {
        s=new Stack<>();
    }

    int next(int price) {
        Stack<Integer> s1=new Stack();
        s.push(price);
        int n=0;
        while(!s.empty()&& price >= s.peek()){
            s1.push(s.pop());
            n++;
        }while(!s.empty()){
            s1.push(s.pop());
        }
        while(!s1.empty()){
            s.push(s1.pop());
        }
        return n;
    }
/*    int next(int price) {
        Stack<Integer> s1=new Stack();
        s.push(price);
        int n=0;
        while(!s.empty()){
            if(price >= s.peek()){
                n++;
            }else{
                break;
            }
            s1.push(s.pop());
        }
        while(!s1.empty()){
            int a=s1.pop();
            s.push(a);
        }
        return n;
    }*/
    public  static void main(String[] args) {

        StockSpanner stockSpanner=new StockSpanner();
        System.out.println(stockSpanner.next(100));
        System.out.println(stockSpanner.next(80));
        System.out.println(stockSpanner.next(60));
        System.out.println(stockSpanner.next(70));
        System.out.println(stockSpanner.next(60));
        System.out.println(stockSpanner.next(75));
        System.out.println(stockSpanner.next(85));
    }
}


